package main

import (
	"SelectCourse/controller"
	"SelectCourse/dao"
	"SelectCourse/routers"
	"fmt"
	"github.com/gin-contrib/sessions"
	"github.com/gin-gonic/gin"
)

func main() {
	dao.InitMySQL()
	err := dao.InitRedisClient()
	if err != nil {
		fmt.Println("连接Redis失败，错误信息：", err)
		return
	}
	fmt.Println("连接redis成功！")
	defer dao.Close()
	r := gin.Default()
	// session 全局中间件
	r.Use(sessions.Sessions("mySession", controller.Store))

	routers.RegisterRouter(r)
	r.Run("0.0.0.0:80")
}
